﻿<!DOCTYPE html>
<html>
<head>
  <title>СРК</title>
  <meta charset="utf-8">
  <script>
  let index=0;
  function onload(){
   let url = new URL(window.location.href);
   index = parseInt(url.searchParams.get("index"));
   showvalues();
  }
  function showvalues() {
    document.getElementById("name1").innerHTML =$TY_SRKC1Name[index];
    document.getElementById("name2").innerHTML =$TY_SRKC2Name[index];
    if($TY_SRKDisconnected[index]!=0){document.getElementById("status1").innerHTML ="Нет связи";
     document.getElementById("status1").style.backgroundColor = "#808080";
     document.getElementById("status2").innerHTML ="Нет связи";
     document.getElementById("status2").style.backgroundColor = "#808080";
     document.getElementById("alr1").innerHTML ="";
     document.getElementById("alr2").innerHTML ="";}
    else{
      if($TY_SRKC1on[index]==0){document.getElementById("status1").innerHTML = "Выключен";
        document.getElementById("status1").style.backgroundColor = "#ffffff";}
	else{document.getElementById("status1").innerHTML = "Включен";
	document.getElementById("status1").style.backgroundColor = "#00FF00";}
      if($TY_SRKC2on[index]==0){document.getElementById("status2").innerHTML = "Выключен";
        document.getElementById("status2").style.backgroundColor = "#ffffff";}
	else{document.getElementById("status2").innerHTML = "Включен";
	document.getElementById("status2").style.backgroundColor = "#00FF00";}
      if($TY_SRKC1alr[index]>0){document.getElementById("alr1").innerHTML = "АВАРИЯ";
        document.getElementById("alr1").style.backgroundColor = "#FF0000";}
	else{document.getElementById("alr1").innerHTML = "Ok";
        document.getElementById("alr1").style.backgroundColor = "#00FF00";}
      if($TY_SRKC2alr[index]>0){document.getElementById("alr2").innerHTML = "АВАРИЯ";
        document.getElementById("alr2").style.backgroundColor = "#FF0000";}
	else{document.getElementById("alr2").innerHTML = "Ok";
        document.getElementById("alr2").style.backgroundColor = "#00FF00";}
    }
    document.getElementById("temp").innerHTML = $TY_SRKTroom[index]+"&deg;C";
    document.getElementById("tempsp").innerHTML = $TY_SRKTsp2[index];
    document.getElementById("tempsp3").innerHTML = $TY_SRKTsp3[index];
    document.getElementById("statall").innerHTML = $TY_SRKStatus[index];
}
function getvalues() {
fetch("TY_SRKDisconnected-TY_SRKC1on-TY_SRKC1alr-TY_SRKTroom-TY_SRKTsp2-TY_SRKTsp3-TY_SRKStatus.json").then(function(response) {
response.text().then(function(text) {
const jsonobj=JSON.parse(text);
TY_SRKDisconnected=jsonobj.TY_SRKDisconnected;
TY_SRKC1on=jsonobj.TY_SRKC1on;
TY_SRKC1alr=jsonobj.TY_SRKC1alr;
TY_SRKTroom=jsonobj.TY_SRKTroom;
TY_SRKTsp2=jsonobj.TY_SRKTsp2;
TY_SRKTsp3=jsonobj.TY_SRKTsp3;
TY_SRKStatus=jsonobj.TY_SRKStatus;
  showvalues();
  });
});
}
let menuvisible=0;
function showmenu(){
 if(menuvisible==0){
  document.getElementById("menu").style.display = "block";
  menuvisible=1;
 } else{
  document.getElementById("menu").style.display = "none";
  menuvisible=0;
 }
}
</script>
  <style>
   body {font-family:arial;
   background-image: url("images/srk.png");
   background-repeat: no-repeat;}
   table {width: 100%;}
   .menu {
    position: absolute;
    display: none;
    left: 1px;
    top: 50px;
    width: 250px;
    height: 100px;
    background-color: white; 
    border:1px solid black;
    z-index: 100;} 
  </style>
</head>
<body onload="onload()">
  <table>
      <tr bgcolor="00C1FF"><td><img src="images/menu36.png" onclick="showmenu()"></td>
      <td width="50%"><label id="name1" style="font-size:30px"> name1 </label></td>
      <td width="50%"><label id="name2" style="font-size:30px"> name2 </label></td>
    </tr>
  </table>
 <div class="menu" id="menu">
  <br>
  <a href="tysrktrend.htm">Тренд параметров >>></a><br><br>
  <a href="tysrktable.htm">Таблица параметров >>></a><br>
 </div>
  <table>
    <tr>
      <td></td><td><h2><label id="status1"> --- </label> <label id="alr1"> --- </label></h2></td>
      <td></td><td><h2><label id="status2"> --- </label> <label id="alr2"> --- </label></h2></td>
      </tr>
      <tr>
        <td></td><td>Температура</td>
        <td><h2><label id="temp"> --- </label></h2></td><td></td>
      </tr>
      <tr>
        <td></td><td>Уставка</td>
        <td>от <label id="tempsp"> --- </label> до <label id="tempsp3"> --- </label></td><td></td>
      </tr>
  </table>
<br>
<br>
(<label id="statall"> --- </label>)
</body>
<script type="text/javascript">
var myint = setInterval("getvalues()",2000);
</script>
</html>
